package com.niit.az;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Unknow extends AppCompatActivity {

    MyBroadcastReceiver myBroadcastReceiver;
    String Tag = "com.niit.Unknow.broadcastReceiver";

    ImageView img_sleep_story;
    ImageView img_homewoek_help;
    ImageView img_fqys;
    ImageView img_wyydcd;
    ImageView img_xyst;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_unknow);

        img_sleep_story = findViewById(R.id.img_sleep_story);
        img_homewoek_help = findViewById(R.id.img_homewoek_help);
        img_fqys = findViewById(R.id.img_fqys);
        img_wyydcd = findViewById(R.id.img_wyydcd);
        img_xyst = findViewById(R.id.img_xyst);

        myBroadcastReceiver = new MyBroadcastReceiver();
        IntentFilter filter = new IntentFilter();
        filter.addAction(Tag);
        registerReceiver(myBroadcastReceiver,filter);

        img_sleep_story.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("info","未来畅想中的睡前故事程序尚未开发完成，敬请期待！");
                intent.setAction(Tag);
                sendBroadcast(intent);
            }
        });

        img_homewoek_help.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("info","未来畅想中的作业帮程序尚未开发完成，敬请期待！");
                intent.setAction(Tag);
                sendBroadcast(intent);
            }
        });

        img_fqys.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("info","未来畅想中的番茄语社程序尚未开发完成，敬请期待！");
                intent.setAction(Tag);
                sendBroadcast(intent);
            }
        });

        img_wyydcd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("info","未来畅想中的网易有道词典程序尚未开发完成，敬请期待！");
                intent.setAction(Tag);
                sendBroadcast(intent);
            }
        });

        img_xyst.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("info","未来畅想中的小猿搜题程序尚未开发完成，敬请期待！");
                intent.setAction(Tag);
                sendBroadcast(intent);
            }
        });
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        unregisterReceiver(myBroadcastReceiver);
    }

    public class MyBroadcastReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent){
            Toast.makeText(context,"您收到的广播为："+intent.getStringExtra("info"),Toast.LENGTH_LONG).show();
        }
    }
}
